< previous page page_536 next page >

Page 536
0536-01.jpg
Figure 24.8
Multiple-key indexes further
refine the logical order of a table.
CAUTION
Although this point might be obvious, I must stress that the order of the fields in the index expression has a dramatic impact on the order of the records in the table. Indexing on first name and then last name produces different results than indexing on last name and then first name. Figure 24.9 shows the undesirable results of using a first name/last name index on the table used in Figure 24.7.

0536-02.jpg
Figure 24.9
An improper index field order
yields undesirable results.
Using Queries
When you normalize data, you typically are placing related information in multiple tables. However, when you need to access the data, you want to see the information from all the tables in one place. To do so, you need to create recordsets that consolidate the related information from the multiple tables. You create a recordset from multiple tables by using an SQL statement that specifies the desired fields, the location of the fields, and the relation between the tables. One way of using an SQL statement is to place it in the Database object's OpenRecordset method, which you use to create the recordset. However, you also can store the SQL statement as a query in the database.
Using stored queries presents several advantages:
You can use the SQL statement more easily in multiple locations in your program or in multiple programs.
Making changes to the SQL statement in a single location is easier.

 
< previous page page_536 next page >